﻿<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>jQuery Contact Form Plugin: FFForm</title>
    <link href="./asserts/css/demo.css" rel="stylesheet" type="text/css">
    <!--<script src="./asserts/js/jquery-1.10.2.min.js" type="text/javascript"></script>-->
    <!--&lt;!&ndash;Framework&ndash;&gt;-->
    <!--<script src="./asserts/js/jquery-1.10.2.min.js" type="text/javascript"></script>-->
    <!--<script src="./asserts/js/jquery-ui.js" type="text/javascript"></script>-->
    <!--&lt;!&ndash;End Framework&ndash;&gt;-->
    <!--<script src="./asserts/js/jquery.ffform.js" type="text/javascript"></script>-->
    <script type="text/javascript" src="webjars/jquery/3.4.1/jquery.min.js"></script>

</head>

<body>

    <section id="getintouch" class="fadeInDownBig animated">
        <div class="container" style="border-bottom: 0;">
            <h1>
                <span>考研概率查询平台</span>
            </h1>
            <h4>
                <a href="./login.html" class="submit" style="text-decoration: none;">去登陆</a>
                <a href="./register.html" class="submit" style="text-decoration: none;">去注册</a>
            </h4>
        </div>
        <div class="container">
            <form class="contact" id="addForm">
                <div class="row clearfix">
                    <div class="lbl">
                        <label>
                            学校</label>
                    </div>
                    <div class="ctrl">
                        <select  id="slelect" name="name" placeholder="请选择"
                                 style="border: 1px solid #e1e1e1;
                                        box-shadow: none;
                                        width: 100%;
                                        height: 36px;
                                        padding: 4px 6px;
                                        font-size: 14px;
                                        line-height: 20px;
                                        color: #555;
                                        border-radius: 4px;
                                        vertical-align: middle;"
                                 onchange="initInput(this)">
                            <option value="1">选项一</option>
                            <option value="2">选项二</option>
                        </select>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="lbl">
                        <label>
                            数据</label>
                    </div>
                    <div class="ctrl">
                        <select  id="slelect2" name="name" placeholder="请选择"
                                 style="border: 1px solid #e1e1e1;
                                        box-shadow: none;
                                        width: 100%;
                                        height: 36px;
                                        padding: 4px 6px;
                                        font-size: 14px;
                                        line-height: 20px;
                                        color: #555;
                                        border-radius: 4px;
                                        vertical-align: middle;"
                                 onchange="infoExcel(this)">
                            <option value="1">---无数据---</option>
                            <!--<option value="2">选项二</option>-->
                        </select>
                    </div>
                </div>
                <div id="box">
                </div>
            </form>
        </div>
    </section>

<script>
    $(function () {
        initSchool();
    })
    function initSchool() {
        $.ajax({
            type: "get",
            dataType: "json",
            url: "/postgraduate/user/school",
            success: function (res) {
                var str = "<option>---请选择---</option>";
                $.each(res.data,function (k,v) {
                    str += "<option value="+v.id+">"+v.schoolname+"</option>"
                })
                $("#slelect").html(str);
            },
            error:function () {
                alert("服务器出错")
            }
        })
    }
    function initInput(obj) {
        var id = $(obj).val();
        $.ajax({
            type: "get",
            dataType: "json",
            url: "/postgraduate/excel/info",
            data: {"id":id},
            success:function (res) {
                if (res.data.length != 0){
                    var str = "<option>---请选择---</option>";
                    $.each(res.data,function (k,v) {
                        str += "<option value="+v.id+">"+v.excelPath+"</option>"
                    })
                    $("#slelect2").html(str);
                } else {
                    var str = "<option>---无数据---</option>";
                    $("#slelect2").html(str);
                    alert("该校没有上传考研数据")
                }
            }
        })
    }
    function infoExcel(obj) {
        var id = $(obj).val();
        $.ajax({
            type: "get",
            dataType: "json",
            url: "/postgraduate/excel/infoExcel",
            data: {"id":id},
            success:function (res) {
                var str = ""
                $.each(res.data,function (k,v) {
                    str += '<div class="row clearfix">\n' +
                        '        <div class="lbl">\n' +
                        '            <label for="name">\n' +
                        '                '+v+'</label>\n' +
                        '        </div>\n' +
                        '        <div class="ctrl">\n' +
                        '            <input type="text" id="'+v+'"name="'+v+'" data-required="true" data-validation="text"\n' +
                        '                   data-msg="Invalid Name" placeholder="请输入">\n' +
                        '        </div>\n' +
                        '    </div>'
                })
                str +=' <div class="row  clearfix">\n' +
                    '                    <div class="span10 offset2">\n' +
                    '                        <input         type="button" name="submit" id="submitBtn" onclick="subBtn()" class="submit" value="点击查询">\n' +
                    '                    </div>\n' +
                    '                </div>'
                $("#box").html(str)
            },
            error:function () {
                alert("服务器错误")
            }
        })
    }

    function subBtn(){
        var data = $("#addForm").serialize();
        var id = $("#slelect").val();
        $.ajax({
            type: "POST",
            url: "/postgraduate/excel/score",
            data: {"data":data},
            dataType: "json",
            success: function (res) {
                var str = '<div class="row clearfix">\n' +
                    '        <div class="lbl">\n' +
                    '            <label for="name">\n' +
                    '                '+'线性回归模型:&emsp;&emsp;&emsp;&emsp;'+res.data[0]+'</label>\n' +
                    '        </div>\n' +
                    '    </div>\n'+
                '<div class="row clearfix">\n' +
                '        <div class="lbl">\n' +
                '            <label for="name">\n' +
                '                '+'逻辑回归模型:&emsp;&emsp;&emsp;&emsp;'+res.data[1]+'</label>\n' +
                '        </div>\n' +
                '    </div>\n'+
                '<div class="row clearfix">\n' +
                '        <div class="lbl">\n' +
                '            <label for="name">\n' +
                '                '+'贝叶斯模型:&emsp;&emsp;&emsp;&emsp;&emsp;'+res.data[2]+'</label>\n' +
                '        </div>\n' +
                '    </div>\n'+
                '<div class="row clearfix">\n' +
                '        <div class="lbl">\n' +
                '            <label for="name">\n' +
                '                '+'决策树模型:&emsp;&emsp;&emsp;&emsp;&emsp;'+res.data[3]+'</label>\n' +
                '        </div>\n' +
                '    </div>'
                $("#box").html(str)
            },
            error: function () {
                alert("服务器内部错误")
            }
        })
    }


</script>

</body>

</html>